cmake_minimum_required(VERSION 3.5)
project(ros2_cpp_opencv_appledetect_demo)

set(CMAKE_CXX_STANDARD 17)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# set(OpenCV_DIR /home/ohos-sdk-linux-ros-OpenHarmony-5.0.3-Release/linux/native/sysroot/vendor/opencv/lib/cmake/opencv4)
set(OpenCV_DIR /home/limbo/ros2_cross_compile_demo/ohos-sdk-linux-ros/linux/native/sysroot/vendor/opencv/lib/cmake/opencv4)

# Find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(OpenCV REQUIRED)

include_directories(
  ${OpenCV_INCLUDE_DIRS}
)

# Publisher node
add_executable(apple_publisher src/apple_publisher.cpp)
ament_target_dependencies(apple_publisher
  rclcpp
  sensor_msgs
)
target_link_libraries(apple_publisher ${OpenCV_LIBS})

# Subscriber node
add_executable(apple_detector src/apple_detector.cpp)
ament_target_dependencies(apple_detector
  rclcpp
  sensor_msgs
)
target_link_libraries(apple_detector ${OpenCV_LIBS})

install(TARGETS
  apple_publisher
  apple_detector
  DESTINATION lib/${PROJECT_NAME}
)

ament_package()